<?php  
/* 
Template Name: Page Giai Phap
*/
?><?php get_header();?>
<div class="cy-content">
	<?php get_sidebar();?>
    <?php get_footer(); ?>
    <div class="cy-content-center">
        <?php locate_template('block/block-search.php', true); ?>
        <div class="cy-content-title">
        <h2>Thư viện</h2>
        </div><!--cy-content-title-->
    		<?php
    		wp_reset_query();
    		//query the post 
    		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;	
    		//query_posts('meta_key=_mf_write_panel_id&meta_value=1&');
    		$loop = new WP_Query(array('post_type'=>'solution','posts_per_page'=>12,'orderby'=>'ASC','paged' => $paged));
   	        while ( $loop->have_posts() ) : $loop->the_post(); //bat dau vong lap ?>
            <div class="cy-horizontal-tintuc-content-item">
                <div class="cy-horizontal-tintuc-content-title">
                    <a href="<?php the_permalink();?>"><?php the_title();?></a>
                </div><!--cy-horizontal-tintuc-content-title-->
        		<div class="cy-horizontal-tintuc-content-image"> 
        		  <img src="<?php echo get('hinh'); ?>" /> 
                </div><!--cy-horizontal-tintuc-ngang-image-->
                <?
        				$content = get_the_excerpt();
        				echo substr($content, 0, 400);
        		?>
          </div><!--cy-horizontal-tintuc-content-item-->
            <?php endwhile; //ket thuc vong lap ?>
            <?php wp_reset_query();?>
            <!--end--> 
    		<center>
            <div class="cy-pagination">
    			<?php
    			// OK, custom tax's dont work nice with query_posts (i think) but they DEF dont work nice with next_posts(), previous_posts() and  posts_nav_link()
    			// SO, got the custom page nav from here:
    			// http://wordpress.org/support/topic/adding-pagination-to-a-wp_query-loop?replies=16
    			if($loop->max_num_pages>1){
    			  if ($paged > 1) { ?>
    				<a href="<?php echo '?page_id='.get_query_var('page_id').'paged=' . ($paged -1); //prev link ?>"><<</a>
    			  <?php
    			  }
    			  for($i=1;$i<=$loop->max_num_pages;$i++){?>
    				<?php if($i==$paged){?>
    				<span><?php echo $i;?></span>
    				<?php } else {?>
    				<a href="<?php echo '?page_id='.get_query_var('page_id').'&paged=' . $i; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?></a>
    			  <?php
    				}//end if
    			  } //end for
    			  if($paged < $loop->max_num_pages){?>
    				<a href="<?php echo '?page_id='.get_query_var('page_id').'paged=' . ($paged + 1); //next link ?>"> >> </a>
    			  <?php
    			  }
    			}?>
            </div><!--cy-pagination-->
    	  </center>
    </div><!--cy-content-center-->  
</div><!--cy-content-->
